package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderSettingDao {

    @Insert("insert into t_ordersetting values (null,#{orderDate},#{number},#{reservations})")
    Integer save(OrderSetting orderSetting);

    @Select("select count(1) from t_ordersetting where orderDate = #{orderDate}")
    Integer findCountByOrderDate(Date orderDate);

    @Update("update t_ordersetting set number=#{number} where orderDate = #{orderDate}")
    void editNumberByOrderDate(OrderSetting orderSetting);

    @Select("select day(orderDate) date,number,reservations from t_ordersetting where orderDate between #{begin} and #{end}")
    List<Map> findOrderSettingByMonth(@Param("begin") String begin, @Param("end") String end);

    @Select("select * from t_ordersetting where orderDate = #{orderDate}")
    OrderSetting findByOrderDate(Date orderDate);

    @Update("update t_ordersetting set reservations=#{reservations} where orderDate = #{orderDate}")
    void editReservationsByOrderDate(OrderSetting orderSetting);
}
